import java.util.Scanner;

/**
 * @author gao
 * @date 2025/6/28 16:34
 */

public class Solution {
    public int wiggleMaxLength(int[] nums) {
        int n = nums.length;

        // 如果数组长度小于2，直接返回数组长度
        if (n < 2) {
            return n;
        }

        // 初始化结果为0，左值为0
        int ret = 0, left = 0;

        for (int i = 0; i < n - 1; i++) {
            int right = nums[i + 1] - nums[i];
            // 如果差值为0，跳过
            if (right == 0) {
                continue;
            }
            // 如果左值乘以差值小于等于0，结果加1
            if (left * right <= 0) {
                ret++;
            }
            // 更新左值为差值
            left = right;
        }
        // 返回结果加1
        return ret + 1;
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        while (in.hasNext()) {
            int n = in.nextInt();
            int[] nums = new int[n];
            for (int i = 0; i < n; i++) {
                nums[i] = in.nextInt();
            }
            Solution solution = new Solution();
            System.out.println(solution.wiggleMaxLength(nums));
        }
    }
}